# $LastChangedDate: 2011-09-09 00:10:19 -0400 (Fri, 09 Sep 2011) $
# LEGAL: COPYRIGHT (C) 2010 JIM E. BROOKS WWW.PALOMINO3D.ORG
# Determine operating-system and OS-specific libraries.
# Notes:
# - See module.txt.
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
# Apple: Determine if MacPorts or Fink is installed.

IF( APPLE )
    FIND_PATH( APPLE_MACPORTS_DIR bin/port /opt/local )
    IF( APPLE_MACPORTS_DIR )
        SET( APPLE_MACPORTS_FOUND "TRUE" )
        SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${APPLE_MACPORTS_DIR}/lib " )
        MESSAGE( STATUS "Found Apple MacPorts: ${APPLE_MACPORTS_DIR}" )
    ELSE()
        FIND_PATH( APPLE_FINK_DIR bin/fink /sw )
        IF( APPLE_FINK_DIR )
            SET( APPLE_FINK_FOUND "TRUE" )
            SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${APPLE_FINK_DIR}/lib " )
            MESSAGE( STATUS "Found Apple Fink: ${APPLE_FINK_DIR}" )
        ENDIF()
    ENDIF()
ENDIF()

#-------------------------------------------------------------------------------
# Macros to add an include directory:

# Macro to add a system include directory.
# A difference is that the compiler will suppress warnings in system headers.
MACRO( ADD_SYSTEM_INCLUDE_DIR )
    SET( DIR ${ARGV0} )
    IF( APPLE )
        # INCLUDE_DIRECTORIES() won't pass -isystem on Apple so do it manually.
        SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${DIR} " )      # C
        SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${DIR} " )  # C++
    ELSE()
        INCLUDE_DIRECTORIES( SYSTEM ${DIR} )
    ENDIF()
ENDMACRO()

# Macro to add an include directory belonging to the project (program/app).
# A difference is that the compiler should issue warnings in a program's header files.
MACRO( ADD_PROJECT_INCLUDE_DIR )
    SET( DIR ${ARGV0} )
    INCLUDE_DIRECTORIES( ${DIR} )
ENDMACRO()
